//
//  AppDelegate.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/9.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "AppDelegate.h"

#import "ByLoginVC.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window setBackgroundColor:[UIColor whiteColor]];
    [self.window makeKeyAndVisible];
    self.window.rootViewController = [ByTabBrController new];
    
    // 地图配置
    self.mapManager = [[BMKMapManager alloc] init];
    BOOL ret = [_mapManager start:@"uhVyh2hPPY99Sq11t1fV9pSvGpCBgSOz"  generalDelegate:nil];
    if (!ret) {
        NSLog(@"manager start failed!");
    }
    
    // 滑动视图在ios11下的适配
    [self scrollAppearanceFit];
    
    // 键盘管理
    [self IQKeyboardManagerInit];
    
    // 判断是否需要登录
//    if (BY_USER) {
//       [self needLogin:NO];
//    }
//    else{
       [self needLogin:YES];
//    }
    
    return YES;
}
#pragma mark --
- (void)needLogin:(BOOL)needLogin{
//    if (needLogin) {
    ByBaseNaviController *loginNavi = [[ByBaseNaviController alloc] initWithRootViewController:[[ByLoginVC alloc] init]];
    self.window.rootViewController = loginNavi;
//    }
//    else{
//        ByTabBarController *vc = [[ByTabBarController alloc] init];
//        self.window.rootViewController = vc;
//    }
}

#pragma mark - 基于ios11的全局适配
- (void)scrollAppearanceFit {
    
    UITableView.appearance.tableFooterView = UIView.new;

    if (@available(ios 11.0,*)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        UITableView.appearance.estimatedRowHeight = 0;
        UITableView.appearance.estimatedSectionFooterHeight = 0;
        UITableView.appearance.estimatedSectionHeaderHeight = 0;
    }
}

#pragma mark - 键盘管理
- (void)IQKeyboardManagerInit {
    
    [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = 100;
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = true;
}













#pragma mark - AppDelegate protocol
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}


@end
